angular.module('mvcApp.mobile-settings', [
    'ngRoute',
    'ngResource'
]).config(['$routeProvider', function ($routeProvider) {
    $routeProvider
        .when('/mobile-settings', {
            templateUrl: 'static/views/mobile-settings.html',
            controller: 'MobileSettingsCtrl'
        });
}]).controller('MobileSettingsCtrl', ['$scope', '$rootScope', '$http', '$location', 'User', '$routeParams', 'Shop', 'Category', 'Product',
    function ($scope, $rootScope, $http, $location, User, $routeParams, Shop, Category, Product) {
        $scope.logout = function () {
            $http.get('/logout')
                .success(function () {
                    $location.path('/login');
                    WebApp.currentUser = {};
                    $rootScope.currentUser = WebApp.currentUser;
                });
        };
        $scope.goToWechatLoginPage = function () {
            User.getWechatLoginUrl()
                .then(function (url) {
                    window.location.href = url;
                }).catch(function (err) {
                    alert(err);
                });
        };
    }]);